package com.itzsj.service.implement;

import com.itzsj.mapper.GraduateMapper;
import com.itzsj.pojo.dto.GJobsDTO;
import com.itzsj.pojo.dto.GMessageDTO;
import com.itzsj.pojo.dto.GResumesDTO;
import com.itzsj.pojo.dto.GSendDTO;
import com.itzsj.pojo.entity.Graduate;
import com.itzsj.pojo.entity.Message;
import com.itzsj.pojo.vo.GJobsVO;
import com.itzsj.service.GraduateService;
import com.itzsj.pojo.vo.GResumesVO;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.time.LocalDateTime;
import java.util.List;

@Service
public class GraduateServiceImpl implements GraduateService {

    @Resource
    private GraduateMapper graduateMapper;

    @Override
    public List<GJobsVO> selectJob(GJobsDTO selectJobDTO) {
        return graduateMapper.select(selectJobDTO);
    }

    @Override
    public void putResume(GSendDTO putResumeDTO) {
        putResumeDTO.setOpTime(LocalDateTime.now());
        graduateMapper.putResume(putResumeDTO);
    }

    @Override
    public Graduate getResume(String sno) {
        return graduateMapper.getInfo(sno);
    }

    @Override
    public void updateResume(String sno, String resume) {
        graduateMapper.updateResume(sno, resume);
    }

    @Override
    public List<GResumesVO> selectResume(GResumesDTO puttedResumeDTO) {
        return graduateMapper.selectResume(puttedResumeDTO);
    }

    @Override
    public void messages(GMessageDTO message) {
        graduateMapper.messages(new Message(message.getSno(), message.getEno(),
                message.getContent(), message.getJobId(), LocalDateTime.now()));
    }

    @Override
    public List<Message> listMessages(String sno, String eno, Integer jobId) {
        return graduateMapper.listMessages(sno, eno, jobId);
    }
}
